﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using VersionManage.Logic;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace VersionManage
{
    public partial class FormVersionManage : Form
    {
        public FormVersionManage()
        {
            InitializeComponent();
        }

        private void 新版本ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ExeVersion ev = null;
            if (dataGridView1.DataSource != null)
            {
                List<ExeVersion> les = (List<ExeVersion>)dataGridView1.DataSource;
                if (les.Count > 0)
                    ev = les[les.Count - 1];
            }

            FormAddVersion fav = new FormAddVersion(ev);
            if (fav.ShowDialog() == DialogResult.OK)
                toolStripComboBox1_SelectedIndexChanged(null, null);
        }

        private void FormVersionManage_Load(object sender, EventArgs e)
        {
            toolStripComboBox1.SelectedText = "3";
        }
          
        private void toolStripComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int appcode = int.Parse(toolStripComboBox1.Text);
            HttpItem hi = new HttpItem { Url = ServicesAddress.VersionManageAddress + "/" + appcode, Method = HttpMethod.Get };
            HttpResult<List<ExeVersion>> httpResult = WebLogic.GetHttpResult<List<ExeVersion>>(hi);
            if (httpResult.Success)
                this.dataGridView1.DataSource = httpResult.Result;
        }
    }
}
